import {request} from "../../request/index.js";
import regeneratorRuntime from '../../lib/runtime/runtime'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    goods:[],
    isFocus:false
  },
  TimeId:-1,
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  handleInput(e){
    const {value}= e.detail;
    if(value.trim()){
      this.setData({
        isFocus:true
      })
      clearTimeout(this.TimeId);
      this.TimeId=setTimeout(()=>{
        this.qsearch(value.trim());
      },1000)
    }
  },
  handleCancel(){
 
  },
  async qsearch(value){
    console.log(value);
    const res = await request({
      url:"goods/qsearch",
      data:{query:value}
    })
    console.log(res);
    this.setData({
      goods:res
    })
  }
})